home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 April
/
EnigmA AMIGA RUN 06 (1996)(G.R. Edizioni)(IT)[!][issue 1996-04][Skylink CD V].iso
/
progs
/
editor
/
write-ed
/
rexx
/
newrev.wrx
< prev
next >
Wrap
Text File
|
1995-05-01
|
6KB
|
271 lines
/*
* NewRev.wrx -- C source revision bumper for WRITE
*
* ©1994 by MGR-Software, Asgard
* written by Lars Hanke
*
* Contact me via:
*
* InterNet: mgr@asgard.bo.open.de
* FIDO: Lars Hanke @ 2:243/4802.22
* AmyNet: Lars Hanke @ 39:170/505.22
*
* Needs the source header to resemble Header.tpl
*
* If the argument is:
* FIRST: the very first comment will be processed
* LAST: the directly preceeding comment will be processed
* anything: the next comment will be processed
*
* Finds the second comment block and
*
* - seeks the entry "Revisor:" and replaces its contents by the contents
* of the "RealName" environment variable
*
* - seeks the entry "Revised:" and replaces its contents by the current
* date
*
* - seeks the entry "Revision:" and increases the post comma number
*
* Finds the last comment block and seeks the entry "HISTORY". Opens
* a new Ed and requests notes on the last changes to place them with
* the current date and revision in standard alignment.
*
* This comment block contains a proper second block and a proper HISTORY
* section!
*
***********************************************************************
*
* Revisor: Lars Hanke
* Revised: 06/04/94
* Revision: 1.3
*
***********************************************************************
*
* HISTORY
*
* Rev: 1.3 -- 06/04/94
* - worked around the WRITE bug
* Rev: 1.2 -- 06/04/94
* - the problem is a WRITE bug, problem reported to the author
* Rev: 1.1 -- 06/04/94
* - got it finally running, seems to be a minor bug if the cursor
* is at the file top
*/
arg cs
IF ~show('P',"WRITE")
THEN DO
say 'This script does not make sense without the "WRITE" editor !'
exit 10
END
address 'WRITE'
options results
'VERSIONCHECK 40000 "NewRev.wrx"'
IF RC~=0 THEN DO
exit 10
END
'LockWindow _CurrentID'
if (RC ~= 0)
then do
'MessageOK "You should have a window!"'
exit 10
end
/* store current position */
'GETVAR "_XPOS"'
a.x=RESULT
'GETVAR "_YPOS"'
a.y=RESULT
/* find the comment block to process */
'SETVAR "_FindString" "/*"'
if(cs="FIRST") then
do
'CursorDown 0'
'Find 1 1 @EOT @EOT {@SILENT @NOWORD}'
if(RC ~= 0) then call terminate("This text does not contain any comment!")
end
else
if(cs="LAST") then
do
c.x = 0
c.y = 0
c.g = 1
'Goto 1 1'
do until ((c.y > a.y) | (c.g = 0))
'Find @CURSOR @CURSOR @EOT @EOT {@SILENT @NOWORD}'
if(RC ~= 0) then
do
if(c.x = 0) then call terminate("This text does not contain any comment!")
else c.g = 0
end
'GETVAR "_XPOS"'
c.x=RESULT
'GETVAR "_YPOS"'
c.y=RESULT
end
'Goto' c.x c.y
end
else do
'Find @CURSOR @CURSOR @EOT @EOT {@SILENT @NOWORD}'
if(RC ~= 0) then call terminate("This text does not contain any comment!")
end
/* store comment position */
'GETVAR "_XPOS"'
c.x=RESULT
'GETVAR "_YPOS"'
c.y=RESULT
/* Find end of comment */
'SETVAR "_FindString" "*/"'
'Find @CURSOR @CURSOR @EOT @EOT {@SILENT @NOWORD}'
if(RC ~= 0) then call terminate("Comment is not call terminated!")
/* store end of comment */
'GETVAR "_XPOS"'
e.x=RESULT
'GETVAR "_YPOS"'
e.y=RESULT
/* find first marker */
'SETVAR "_FindString" " *****"'
'Find' c.x c.y e.x e.y '{@SILENT @NOWORD}'
if(RC ~= 0) then call terminate("No comment block marker found!")
/* and store it */
'GETVAR "_XPOS"'
f.x=RESULT
'GETVAR "_YPOS"'
f.y=RESULT
/* find second marker */
'Find @CURSOR @CURSOR' e.x e.y '{@SILENT @NOWORD}'
if(RC = 0) then
do
'GETVAR "_XPOS"'
s.x=RESULT
'GETVAR "_YPOS"'
s.y=RESULT
/* now process second comment section */
if(skip_clear("Revisor:",CLEAR) = 0) then
do
IF Open(File,"ENV:RealName",r) THEN
DO
Name = READLN(File)
call Close(File)
END
ELSE DO
'GetString (Please enter your name:) "" {@TOMOUSE}'
'GETVAR "_RS"'
Name = RESULT
END
'WriteText "'||Name||'"'
end
if(skip_clear("Revised:",CLEAR) = 0) then
do
'WriteText "'||date('E')||'"'
end
if(skip_clear("Revision:",noclear) = 0) then
do
'GetVar "_CurrentLine"'
line = RESULT
'GetVar "_XPos"'
xp = RESULT
line = delstr(line,1,xp-1)
line = strip(line)
pt = pos('.',line)
if(pt = 0) then call terminate("Bad revision entry!")
pt = pt + 1
rev = substr(line,pt)
line = left(line,pt-1)
rev = rev + 1
ver = line || rev
'DeleteArea @CURSOR @CURSOR @EOL @EOL'
'WriteText "' ver||'"'
end
else call terminate("No revision entry found!")
end
/* find the HISTORY section */
'SetVar "_FindString" " *****"'
'Goto' c.x c.y
do until (RC ~= 0)
'Find @CURSOR @CURSOR' e.x e.y '{@SILENT @NOWORD}'
if(RC = 0) then
do
'GETVAR "_XPOS"'
s.x=RESULT
'GETVAR "_YPOS"'
s.y=RESULT
end
end
'SetVar "_FindString" "HISTORY"'
'Find' s.x s.y e.x e.y '{@SILENT @WORD}'
if(RC = 0) then
do
'CursorDown 0'
'Goto @EOL @EOL'
'Return'
'WriteText "* Rev:' left(ver,7,' ') '--' date('E') '"'
'Return'
'WriteText "* - "'
end
else 'Goto' a.x a.y
'LockWindow 0'
exit 0
skip_clear: procedure EXPOSE f. s.
parse arg item, mode
'SETVAR "_FindString" ('||item||')'
'Find' f.x f.y s.x s.y '{@SILENT}'
ret = RC
if(RC = 0) then
do
'GETVAR "_XPOS"'
x = RESULT
x = x + length(item)
'Goto' x '@CURSOR'
if(mode = "CLEAR") then
do
'DeleteArea @CURSOR @CURSOR @EOL @EOL'
'WriteText " "'
end
end
return ret
terminate: procedure EXPOSE a.
parse arg message
'MessageOK ('||message||')'
'Goto' a.x a.y
'LockWindow 0'
exit 0